<?php
namespace App\Services\TextRecord;
use App\Model\TextRecord;
use App\Services\CommonService;

class TextRecordService extends CommonService
{
     public function add(&$data)
     {
          $result=TextRecord::insert(
              [
                  'textre_uid'=>1,
                  'textre_scord'=>$data['textre_scord'],
                  'text_id'=>$data['text_id'],
                  'ceshi_type'=>$data['ceshi_type'],
                  'textre_stoptime'=>time()
              ]
          );
          if($result===true)
          {
               return $this->success('添加成功');
          }
          else
          {
               return $this->fail(211,'添加测试题计入失败');
          }
     }

     public function CheckOneByIDandChetype($data){
          $dataInfo=TextRecord::where("ceshi_type","=",$data)
               ->where('textre_uid',"=",1)
               ->orderBy("textre_id","desc")
               ->take(1)
               ->get()
              ->toArray();
          if($dataInfo===array())
          {
               return $this->fail(212,'查询测试结果失败');
          }
          return  $this->success($dataInfo);
     }
}